package com.upic.serviceImpl;

import com.upic.po.jurisdiction.RoleResource;
import com.upic.repository.RoleResourceRepository;
import com.upic.service.RoleResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhubuqing on 2018/2/7.
 */
@Service("roleResourceService")
public class RoleResourceServiceImpl implements RoleResourceService {
    @Autowired
    private RoleResourceRepository roleResourceRepository;

    @Override
    public RoleResource saveRoleResource(RoleResource roleResource) {
        return roleResourceRepository.save(roleResource);
    }

    @Override
    public String deleteRoleResource(long roleResourceId) {
        roleResourceRepository.delete(roleResourceId);
        return "SUCCESS";
    }

    @Override
    public Page<RoleResource> searchRoleResource(Pageable pageable) {
        return roleResourceRepository.findAll(pageable);
    }

    @Override
    public List<RoleResource> searchRoleResource() {
        return roleResourceRepository.findAll();
    }

    @Override
    public RoleResource findOne(long roleResourceId) {
        return roleResourceRepository.findOne(roleResourceId);
    }

    @Override
    public RoleResource updateRoleResource(RoleResource roleResource) {
        return roleResourceRepository.saveAndFlush(roleResource);
    }
}
